package com.exampleyyy.demoyyy.controller;

import com.exampleyyy.demoyyy.JieKouService.AliPayServiceJieKou;
import com.exampleyyy.demoyyy.ShiTiYYY.Zhifubao;
import com.exampleyyy.demoyyy.common.AlipayApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

// POST   127.0.0.1:8081/alipay
@RestController
public class PayController {
   @Component("customPayController")
   public class payController {
       // 类内容
   }

    @Autowired// 装配支付的服务层接口
    private AliPayServiceJieKou alipayservicejiekou;

    @PostMapping("/alipay")
    public String alipay(String outTradeNo, String subject,
                         String totalAmount, String description) throws AlipayApiException {
        Zhifubao zhifubao = new Zhifubao();
        // 创建实体类对象
        zhifubao.setOut_trade_no(outTradeNo); // 订单编码
        zhifubao.setSubject(subject);  // 订单主题
        zhifubao.setTotal_amount(totalAmount); // 订单金额
        zhifubao.setDescription(description); // 订单描述
        // 给支付对象设置 4个属性
        System.out.println("订单详情"+zhifubao);
        return alipayservicejiekou.AliPay(zhifubao);
    }
}